home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
yspred
/
sprite.c
next >
Wrap
Text File
|
1993-07-08
|
1KB
|
59 lines
#include <spr.h>
void SPR_setPosiAndAttr(int ns,int xs,int ys,int x,int y,int atr,int col)
{
int pn,lx,ly,spp,stx,sty,i,j,rol,tmp;
if((atr & 0x7c00)==0)
{
SPR_setPosition(0,ns,xs,ys,x,y);
SPR_setAttribute(ns,xs,ys,atr,col);
return;
}
if(atr & 0x0400)lx=8; else lx=16;
if(atr & 0x0800)ly=8; else ly=16;
if(col & 0x8000)spp=1; else spp=4;
rol=(atr & 0x7000)/0x1000;
if(4<=rol && rol<8){tmp=xs; xs=ys; ys=tmp;}
switch(rol)
{
case 0: stx= 1; sty= 0; pn=0;
break;
case 1: stx= 1; sty=-xs*2; pn=xs*(ys-1);
break;
case 2: stx=-1; sty= xs*2; pn=xs-1;
break;
case 3: stx=-1; sty= 0; pn=xs*ys-1;
break;
case 4: stx= ys; sty=1-xs*ys; pn=0;
break;
case 5: stx= ys; sty=-xs*ys-1; pn=ys-1;
break;
case 6: stx=-ys; sty=1+xs*ys; pn=ys*(xs-1);
break;
case 7: stx=-ys; sty= xs*ys-1; pn=xs*ys-1;
break;
}
xs*=spp;
ys*=spp;
pn=(atr & 1023)+pn*spp;
atr=(atr&0xfc00);
for(j=0; j<ys; j++)
{
for(i=0; i<xs; i++)
{
SPR_setPosition(0,ns,1,1,x+i*lx,y+j*ly);
SPR_setAttribute(ns,1,1,atr+pn,col);
ns++;
pn+=stx;
}
pn+=sty;
}
}